from helpers import updateInfo
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class MainPage(webapp.RequestHandler):
    """ Delete all datastore class """

    def get(self):

        q_0 = db.GqlQuery("SELECT * FROM CronJ")
        for p in q_0:
            p.delete()
        
        q_0 = db.GqlQuery("SELECT * FROM YahooCronJ")
        for p in q_0:
            p.delete()
            
        q_1 = db.GqlQuery("SELECT * FROM Competition")
        for p in q_1:
            p.delete()
        
        q_1 = db.GqlQuery("SELECT * FROM Stocks")
        for p in q_1:
            p.delete()
            
        q_2 = db.GqlQuery("SELECT * FROM StocksData")
        for p in q_2:
            p.delete()
            
        q_3 = db.GqlQuery("SELECT * FROM StocksCategories")
        for p in q_3:
            p.delete()
        q_4 = db.GqlQuery("SELECT * FROM TrendUsers")
        for p in q_4:
            p.delete()
        q_5 = db.GqlQuery("SELECT * FROM HistoryUsers")
        for p in q_5:
            p.delete()
        q_6 = db.GqlQuery("SELECT * FROM ETFData")
        for p in q_6:
            p.delete()
        q_7 = db.GqlQuery("SELECT * FROM Comment")
        for p in q_7:
            p.delete()
        
        q_8 = db.GqlQuery("SELECT * FROM NewsFeeds")
        for p in q_8:
            p.delete()
        
            
        cronp=updateInfo.CronJ()
        cronp.put()
        yahoocronp=updateInfo.YahooCronJ()
        yahoocronp.put()

application = webapp.WSGIApplication(
                                     [('/delete', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
